package com.verbetia.musictrends.web.music;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.verbetia.musictrends.persistence.hsqldb.MusicEntity;
import com.verbetia.musictrends.persistence.hsqldb.MusicsPersMngr;
import com.verbetia.musictrends.persistence.hsqldb.UserEntity;
import com.verbetia.musictrends.persistence.hsqldb.UsersPersMngr;
import com.verbetia.musictrends.persistence.hsqldb.Utils;

public class ViewMusic extends HttpServlet{

	private boolean authenticated = false;
	
	String userid;
	String username;
	UserEntity profile = null;			
	
	
	public void setUserid(String userid)
	{
		this.userid = userid;			
		
	}
	
	public String getUserid()
	{
		return this.userid;
	}

	public void setProfile(Object profile)
	{
		this.profile = (UserEntity) profile;	
		
		System.out.println("NONON " + this.profile.toString());
		
	}

	public Object getProfile()
	{
		return "";
	}

	
	public ArrayList<MusicEntity> processSongs(Object o)
	{
		/*
		profile = new UserEntity();
		profile.setUserid("1");
		profile.setUsername("gipsh");
			*/
		ArrayList<MusicEntity> songs = null;	
		
		UserEntity userProfile = (UserEntity)o;
		
		System.out.println("profile here: " + userProfile.toString());
		
		
		MusicsPersMngr music = new MusicsPersMngr();
				
		
        try  			
        {
		 songs = 	Utils.rs2MusicEntity(
				 			music.selectQuery(userProfile.getUserid(), 0)
				);
        } catch (SQLException sqle)
        {
        	System.out.println(sqle);
        }

        return songs;
		
	}
	
	
	
	
}
